#include "Data.h"

Data::Data() {
	_taskNumber = 0;
}

Data::~Data() {}

Data::DataFeedback Data::executeAdd( Task taskToAdd ) {
	
	taskToAdd.setTaskID(_taskNumber);
	_taskNumber++;
	_list.push_back(taskToAdd);
	return SUCCESS;
	
}

Data::DataFeedback Data::executeDeleteTaskID(unsigned int index) {

	if ( index < _list.size() ) {

		for(unsigned int i = index ; i < _list.size() - 1 ; i++ ){

			_list[i] = _list[i+1] ;

		}

		_list.pop_back();
		
		return SUCCESS;
	}
	
	else {
		
		return FAILURE;
	}
}

Data::DataFeedback Data::executeClear() {

	_list.clear();
	_taskNumber = 0;

	if( _list.size() == 0 )
	
		return SUCCESS;

	else
		
		return FAILURE;

}

Data::DataFeedback Data::executeEdit( Task taskToEdit, int indexOfTask ) {

	return SUCCESS;

}

Data::DataFeedback Data::getAll( vector<Task>& tasks ) {

	if( _list.empty() )
		return FAILURE;

	for( unsigned int i = 0 ; i < _list.size() ; i++ )
		tasks.push_back( _list.at(i) );

	return SUCCESS;

}

Data::DataFeedback Data::getByName( vector<Task>& tasks, string taskName ) {

	return SUCCESS;
}

Data::DataFeedback Data::getByID( vector<Task>& taskPointers, int taskId ) {

	return SUCCESS;
}

Data::DataFeedback Data::getBySearchTerm ( vector<Task>& tasks, string searchTerm ) { 

	return SUCCESS;

}

Data::DataFeedback Data::getByTime (  vector<Task>& tasks, ptime startTime, ptime endTime ) {

	return SUCCESS;

}

Data::DataFeedback Data::getByDone( vector<Task>& taskPointers ) {

	return SUCCESS;
}

Data::DataFeedback Data::executeSort(  string typeOfSort ) {

	return SUCCESS;
}

Data::DataFeedback Data::executeLoad( vector<Task> list ) {

	return SUCCESS;

}

int Data::getNumberOfTasks() {
	return _taskNumber;
}